#include <iostream>
#include <unistd.h>
#include "thread.hpp"

//应用方的视角
string GetThreadName()
{
    static int number = 1;
    char name[64];
    snprintf(name, sizeof(name), "Thread-%d", number++);
    return name;
}

void Print()
{
    while(true)
    {
        cout << "hello world" << endl;
        sleep(1);
    }    
}

int main()
{
    Thread t(Print, GetThreadName());
    cout << "is thread running ? " << t.IsRunning() << endl;
    t.start();
    cout << "is thread running ? " << t.IsRunning() << endl;
    t.join();
    return 0;
}